using Microsoft.VisualBasic;
using Microsoft.VisualBasic.CompilerServices;
using SJVars;
using Spacejock;
using System;
using System.Collections;
using System.IO;
using System.Windows.Forms;
using yW5Lib;

namespace yWriter6
{
	public class clsEpub
	{
		public static string strDefaultMobiParam = "--input-profile=default --output-profile=kindle --disable-font-rescaling --change-justification=\"justify\" --mobi-ignore-margins  --toc-filter=\"Unnamed\"";

		public static string strDefaultEpubParam = "--input-profile=default --output-profile=kobo --disable-font-rescaling --no-default-epub-cover --flow-size=260 --change-justification=\"justify\" --toc-filter=\"Unnamed\"";

		public static string CreateFilenameFromExportName(string strExportName)
		{
			return Path.Combine(modVariables.DATAPATH, strExportName + ".ybebk");
		}

		public static void FillExporterCombo(clsProject cProject, ref ComboBox cmbExporters, string strDefault)
		{
			cmbExporters.Items.Clear();
			Collection AllFiles = new Collection();
			clsSettings clsSettings = new clsSettings(ref clsShared.cLog);
			clsShared.cFile.FillFiles(modVariables.DATAPATH, ".ybebk", ref AllFiles);
			IEnumerator enumerator = default(IEnumerator);
			try
			{
				enumerator = AllFiles.GetEnumerator();
				while (enumerator.MoveNext())
				{
					string path = Conversions.ToString(enumerator.Current);
					clsSettings.LoadSettings(Path.Combine(modVariables.DATAPATH, path));
					cmbExporters.Items.Add(clsSettings.sGet("ExportName", "Unknown Exporter"));
				}
			}
			finally
			{
				if (enumerator is IDisposable)
				{
					(enumerator as IDisposable).Dispose();
				}
			}
			if (strDefault.Length > 0)
			{
				cmbExporters.SelectedIndex = cmbExporters.FindStringExact(strDefault);
			}
		}

		public static void SetExporterIndex(string ExporterName, ref ComboBox cmbExporters)
		{
			int num = cmbExporters.FindStringExact(ExporterName);
			if (num >= 0)
			{
				cmbExporters.SelectedIndex = num;
			}
		}
	}
}
